home *** CD-ROM | disk | FTP | other *** search
- Sample programs 64 and 65, EXAMPLE64.PRO and EXAMPLE65.C, respectively,
- demonstrate how to access a subroutine written in C from a Turbo Prolog
- program.
-
- Any C compiler that can compile large memory model can be used to
- compile C modules for use with Prolog. However, any compiler that puts
- an '_' AFTER public identifiers (i.e. example becomes example_) cannot
- be used with Turbo Prolog.
-
- Lattice C 2.15 and 3.0 were used to compile EXAMPL65.C to an .OBJ file.
-
- Note: Large memory models must be used when linking
- modules to Turbo Prolog from any other language.
-
- GENERAL NOTES
- -------------
-
- Using the C compiler, version 2.15 issue the following commands:
-
- LC1 EXAMPL65 -mL -N -S -iC -b
- LC2 EXAMPL65 -v
-
- using the C compiler, version 3.0 issue the following command after
- reading the note below:
-
- LCL EXAMPLE65
-
- NOTE: Remove stack checking by adding the -v option to LCL.BAT.
-
- The above compilation produces a new file: EXAMPL65.obj
-
- Compile EXAMPL64.PRO to an OBJ file. Use DOS LINK.EXE to link together
- the Prolog and C modules and create an .EXE file. Below is an example
- of the link statement:
-
- link init exampl64 exampl65 exampl64.sym,first,,prolog
-
- This results in the creation of FIRST.EXE.
-
-
- PARAMETER PASSING
- -----------------
- Integers, characters and reals are passed on the stack by value.
- Their corresponding data types in C are int, char and double
- respectively. Unbound variables are passed as pointers (i.e. an
- unbound integer X would be called from C as int *X).
-
- Strings and symbols are passed as character pointers (ie. char
- *string) to external routines. An unbound string or symbol is passed
- as a pointer to a pointer to character (ie. char **string).
-
- Functors and lists are passed as structures. EXAMPL65.C is an
- example of how functors and lists are passed to C.
-
- For more information on passing parameters to C see page 156 of the
- manual.